package com.atguigu.schedule.dao.impl;

import com.atguigu.schedule.dao.BaseDao;
import com.atguigu.schedule.dao.SysUserDao;
import com.atguigu.schedule.pojo.SysUser;

import java.util.List;

public class SysUserDapImpl extends  BaseDao implements SysUserDao {


    @Override
    public int addSysUser(SysUser sysUser) {
      try {
          String sql = "insert into sys_user values(DEFAULT,?,?)";
          return baseUpdate(sql,sysUser.getUsername(), sysUser.getUser_pwd());
      }catch (Exception e){
          throw new RuntimeException();
      }
    }

    @Override
    public SysUser findByUsername(String username) {
        String sql="select uid,username,user_pwd from sys_user where username=?";
        List<SysUser> sysList = baseQuery(SysUser.class, sql, username);
        return !sysList.isEmpty() ?sysList.get(0):null;
    }
}
